/**
* @file main.cpp
* @brief this program shows that how to use systme calls to 
* @author Shuda Li<lishuda1980@gmail.com>
* @version 1.0
* @date 2011-01-21
*/
#include <iostream>
#include <string>
#include <stdio.h> 
#include <stdlib.h> 
#include <boost/lexical_cast.hpp>

#define ROWS 13
#define COLS 26

using boost::lexical_cast;
using boost::bad_lexical_cast;
using namespace std;

int main()
{
    string sPanoid;
    cout << "Enter a panoid: ";
    cin >> sPanoid;

    string sComm = "wget \"cbk0.google.com/cbk?output=tile&panoid=" + sPanoid + "&zoom=5"; 
    
    for ( int x = 0 ; x < COLS ; x++ )
    {
        for ( int y = 0 ; y < ROWS ; y++ )
        {
            string sAnd;
            string sX = lexical_cast<string> ( x );
            string sY = lexical_cast<string> ( y );

            sAnd = sComm + "&x=" + sX + "&y=" + sY + "\"" + " -O " + "images/" + sX + "_" + sY + ".jpg";
            cout << sAnd << endl;

            system ( sAnd.c_str() );
        }
    }

    return 0;
}
